<?php
/**
 * Authorization gate for administrators-only areas
 *
 * @package Concerto
 * @subpackage Auth
 * @author Jason Raede <jason@torchdm.com>
 */
namespace application\auth;
use application\system\Gandalf;

class Admin {
	
	/**
	 * Checks if the user is an administrator
	 *
	 * @return bool TRUE or FALSE if administrator/not
	 */
	public function authorized() {
		global $concerto;
		
		
		if($concerto->User->isAdmin()) return TRUE;
		return FALSE;
	}
	
	/**
	 * Handles authorization errors if the above check fails
	 *
	 * @param const $error The error thrown
	 */
	public function handleError($error) {
		global $concerto;
		$currentUrl = $concerto->UrlInterpreter->currentUrl;
		switch($error) {
			case ERROR_UNAUTHORIZED:
				header('location: '.CN_URL.'login/?alert=login_required&redirect='.str_replace('http://', '', $currentUrl));
				break;
		}
	}
}
?>